#ifndef PRIVATECHAT_H
#define PRIVATECHAT_H

#include <QWidget>
#include<QScrollBar>
#include <QScrollArea>
#include <QLineEdit>
#include <QVBoxLayout>
#include <QPushButton>
#include"chatbubble.h"
#include"Protocol.h"
#include<QTextCursor>

namespace Ui {
class PrivateChat;
}

class PrivateChat : public QWidget
{
    Q_OBJECT

public:
    explicit PrivateChat(QWidget *parent = nullptr);
    ~PrivateChat();

    void setChatName(QString name);

    void updateMsg(QString msg);

    QString chatName() const;

    //设置消息格式
    void appendLine(const QString &text, const QColor &color, Qt::Alignment alignment,const QColor& bgColor);

    void appendLine(const QString &text,const QString &timeText,int bubbleType);

private slots:
    void sendMessage();

private:
    Ui::PrivateChat *ui;

    //聊天对象
    QString m_chatName;

    QVBoxLayout *chatLayout;
    QLineEdit *input;
    QScrollArea *scrollArea;

    //
    // QTextCursor m_cursor;
};

#endif // PRIVATECHAT_H
